package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.domain.CouponProductCategoryRelation;
import com.itheima.mapper.CouponProductCategoryRelationMapper;
import com.itheima.service.SmsCouponProductCategoryRelationService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class SmsCouponProductCategoryRelationServiceImpl implements SmsCouponProductCategoryRelationService {

    @Autowired
    CouponProductCategoryRelationMapper smsCouponProductCategoryRelationMapper;

    //优惠卷绑定的商品分类
    //添加分类
    @Override
    public void save(CouponProductCategoryRelation smsCouponProductCategoryRelation) {
        smsCouponProductCategoryRelationMapper.insert(smsCouponProductCategoryRelation);
    }

    //删除分类
    @Override
    public void delete(Integer id) {
        LambdaQueryWrapper<CouponProductCategoryRelation> lqw = new LambdaQueryWrapper<>();
        lqw.eq(CouponProductCategoryRelation::getCouponId, id);
        smsCouponProductCategoryRelationMapper.delete(lqw);
    }

    //分类集合
    @Override
    public List<CouponProductCategoryRelation> selectById(Long id) {
        LambdaQueryWrapper<CouponProductCategoryRelation> lqw = new LambdaQueryWrapper<>();
        lqw.eq(CouponProductCategoryRelation::getCouponId, id);
        List<CouponProductCategoryRelation> productCategoryRelationList = smsCouponProductCategoryRelationMapper.selectList(lqw);
        return productCategoryRelationList;
    }

}
